//
//  ListeView.m
//  WeiWeiHaircut
//
//  Created by apple on 15/12/8.
//  Copyright © 2015年 超群. All rights reserved.
//

#import "ListeView.h"
#import "QZShopCategory.h"

@interface ListeView()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UITableView* tableView;

@end

@implementation ListeView{
    
    CGFloat _tableViewH;
}


-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        
        
        self.layer.masksToBounds = YES;
        self.userInteractionEnabled = YES;
        self.image = [UIImage imageNamed:@"矩形-27"];
        _tableViewH = frame.size.height;
        
        
        [self createTableView];

    }
    return self;
}




-(void)createTableView{
    
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, self.frame.size.width-10, self.frame.size.height-20)style:UITableViewStylePlain];
    
    _tableView.backgroundColor = [UIColor clearColor];
    _tableView.delegate = self;
    _tableView.dataSource = self;

    [self addSubview:_tableView];
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.datas.count;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];

    if (cell== nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    QZShopCategory *model =  _datas[indexPath.row];
    
    cell.textLabel.text = model.proName;
    
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    
    cell.textLabel.textColor = [UIColor darkGrayColor];
 
    cell.textLabel.font = [UIFont systemFontOfSize:15];

    return cell;
    
}


-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 30;
}


-(void)setDatas:(NSArray *)datas{
    
    _datas = datas;
    
    [_tableView reloadData];
    
    
}
-(void)lisetViewHieddn{
    [UIView animateWithDuration:0.2 animations:^{
        
        CGRect tmpFrame = self.frame;
        tmpFrame.size = CGSizeMake(tmpFrame.size.width, 0);
        self.frame = tmpFrame;
        
    }];
    
    
}
-(void)lisetViewShow{
     [UIView animateWithDuration:0.2 animations:^{
    CGRect tmpFrame = self.frame;
    tmpFrame.size = CGSizeMake(tmpFrame.size.width, _tableViewH);
    self.frame = tmpFrame;
        }];
}

@end
